<template>
  <div class="setWeightLoad">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="允许超载" prop="id_num">
        <el-switch
          v-model="form.is_overload"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
        <!-- :active-text="'允许超载'"
          :inactive-text="'不允许超载'" -->
      </el-form-item>
    </el-form>

    <div class="dialog-footer">
      <el-button type="default" @click="$emit('close')">取消</el-button>
      <el-button type="primary" @click="sure">设置</el-button>
    </div>
  </div>
</template>

<script>
import {setWeightLoad} from "@/api/childCompany/waybill";
export default {
  name: "setWeightLoad",
  props:{
    weightLoadRow:{
        default:{},
        type:Object
    }
  },
  data() {
    return {
        form:{
            is_overload:0
        }
    };
  },
  mounted(){
      this.initial()
  },
  methods: {
        async initial(){
            this.form.is_overload = this.weightLoadRow.is_overload;
        },
        async sure(){
            let result = await setWeightLoad(
                {
                    is_overload:this.form.is_overload,
                    id:this.weightLoadRow.id
                }
            )
            if(result.code == 200){
                this.$message({
                    type:'success',
                    message:'设置成功'
                })
                this.$emit('refresh')
            }  

        }
  }
};
</script>

<style lang="scss" scoped>
.setWeightLoad{
    .dialog-footer {
    display: flex;
    justify-content: center;
  }
}
</style>
